package com.example.xx.config;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;

public class Jwtjie {
    public static void main(String[] args) {
        String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDMwNDYyNTYsImlhdCI6MTc0Mjk1OTg1NiwibmFtZSI6IuW8oOS4iSIsImlkIjoiMSJ9.BODDHX9N-ld9_5G8IBCWTBI7l5_kz01yaf9KaJUJxkY";
        // 设置密钥
        JwtParser qqqq = Jwts.parser().setSigningKey("qqqq");
        // 将jwt的第二部分解析出来
        Jws<Claims> claimsJws = qqqq.parseClaimsJws(jwt);
        Claims body = claimsJws.getBody();
        System.out.println(body.get("name"));
        System.out.println(body.get("id"));
        System.out.println(body);
    }
}
